// api.js
const request = require('./request.js'); // 引入封装的 request 模块

// 定义 API 方法
const API = {
  //微信自带的方法

  //获取用户模糊位置
  getFuzzyLocation : () =>
    new Promise((resolve, reject) =>
    wx.getFuzzyLocation({ type: 'wgs84', success: resolve, fail: reject })
  ),

  //调用你三方接口
  thirdRequest : (options) =>
    new Promise((resolve, reject) =>
    wx.request({ ...options, success: resolve, fail: reject })
  ),


  //用户登录接口
  userLogin:(data)=>request.post('/wechat/login',data),
  //获取当前登录用户信息接口
  userInfo:()=>request.get('/wechat/userInfo'),
  //更新用户头像 昵称
  updateUserInfo:(data)=>request.uploadFile('/wechat/updateUserInfo',data),
  updateUserInfoNoAvatar:(data)=>request.post('/wechat/updateUserInfo1',data),
  //退出登录
  logout:()=>request.get('/wechat/logout'),
  //智能聊天
  chatAi:(data,header)=>request.get('/wechat/ai/chat',data,header),
  //数据录入
  materialInfoSave:(data)=>request.post('/wechat/materialInfo/save',data),
  //数据查询
  materialInfoList:(data)=>request.post('/wechat/materialInfo/list',data),
  //出入库
  materialRecordSave:(data)=>request.post('/wechat/materialRecord/save',data),
  //物料删除
  materialInfoDelete:(id)=>request.post('/wechat/materialInfo/del/'+id),

  //首页签到列表数据
  signDataList:(data)=>request.get('/wechat/sign/dataList',data),
  //用户签到
  signIn:(id,data)=>request.post('/wechat/sign/signIn/'+id,data),

  //生成二维码图片
  jsonQr:(id)=>request.get('/wechat/sign/jsonQr/'+id),
  //发布接口
  signAdd:(data)=>request.post('/wechat/sign/signAdd',data),
  //获取签到结果
  signResult:(id)=>request.get('/wechat/sign/signResult/'+id),
  //获取本人发布的数据
  getPublished:()=>request.get('/wechat/sign/getPublished'),
   //发布未发布的
  publishSignData:(id)=>request.get('/wechat/sign/publish/'+id),
  //删除未发布的
  deleteSignData:(id)=>request.get('/wechat/sign/delete/'+id),

  //获取当前用户的队伍列表
  orgUserList:(param)=>request.get('/wechat/org/list',param),

  //通用文件上传
  orgAdd:(data)=>request.uploadFile('/wechat/org/Add',data),

  //组织邀请的二维码
  orgJsonQr:(id)=>request.get('/wechat/org/jsonQr/'+id),

  //组织邀请的二维码
  orgJoin:(id)=>request.post('/wechat/org/join/'+id),

   //组织解散
  orgDelete:(id)=>request.post('/wechat/org/delete/'+id),
  //菜谱查询
  cookQuery:(name)=>request.get('/wechat/cook/query?name='+name)
};

module.exports = API;
